package com.kws.merchant.mapper;

import com.kws.merchant.domain.AfterSalesWarranty;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kws.merchant.domain.ContractSignature;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 售后-保修单(AfterSalesWarranty)表数据库访问层
 *
 * @author yxy
 * @since 2024-10-22 19:23:10
 */

public interface AfterSalesWarrantyMapper extends BaseMapper<AfterSalesWarranty> {


    @Select("SELECT count(*) from tb_after_sales_warranty a left join tb_merchant u  on a.merchant_id=u.id left join tb_item i  on a.item_id=i.id where ${sql};")
    int countToTal(@Param("sql") String sql);

    @Select("SELECT a.*,u.company_name as merchant_name,i.item_name,s.nick_name as user_name,d.`name` as device_name from tb_after_sales_warranty a left join tb_merchant u  on a.merchant_id=u.id left join tb_item i  on a.item_id=i.id left join sys_user s on s.user_id=a.user_id left join tb_device d on d.id=a.device_id  where ${sql} limit ${sizeNum},${totalPage}")
    List<AfterSalesWarranty> getRecords(@Param("sql") String sql, @Param("sizeNum") Integer sizeNum, @Param("totalPage") Integer totalPage);

    @Select("SELECT a.*,u.company_name as merchant_name,i.item_name,s.nick_name as user_name,d.`name` as device_name from tb_after_sales_warranty a left join tb_merchant u  on a.merchant_id=u.id left join tb_item i  on a.item_id=i.id left join sys_user s on s.user_id=a.user_id left join tb_device d on d.id=a.device_id  where a.id=${id};")
    AfterSalesWarranty detailById(@Param("id") Long id);
}
